package com.lyl.controller;

import com.alibaba.alicloud.sms.ISmsService;
import com.lyl.domain.Sms;
import com.lyl.model.Result;
import com.lyl.service.SmsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author lylbell
 * @date 2021-06-30 12:44
 */
@RestController
@Api(tags = "短信接口")
@RequestMapping("/sms")
public class SmsController {

    @Autowired
    private SmsService smsService;

    @GetMapping("/sendTo")
    @ApiOperation("给手机号发送短信")
    @ApiImplicitParam(name = "sms",value = "短信相关信息")
    public Result sendMessage(@RequestBody @Validated Sms sms) {
        Boolean isOK = smsService.sendMessage(sms);
        if (isOK) {
            return Result.ok("发送成功");
        }
        return Result.fail("发送失败");
    }
}
